package com.xujl.rxtask.dualtest;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.xujl.rxtask.R;
import com.xujl.task.Emitter;
import com.xujl.task.dual.DualManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class DualTestActivity2 extends AppCompatActivity {
    private static final String TAG = "DualTestActivity";
    long count1;
    long time;

    @Override
    protected void onCreate (@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dual_test_1);
        count1 = getIntent().getIntExtra("count", 10);
        final TextView tv1 = findViewById(R.id.tv1);
        tv1.setText("" + count1);
        DualManager.getInstance().addTasks(new DualManager.Callback() {
            @Override
            public boolean run (Emitter<DualManager.Callback> emitter) {
                for (int i = 0; i < count1; i++) {
                    Log.i(TAG, "testCount: " + i);
                }
                return false;
            }
        });
        findViewById(R.id.btn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick (View v) {
                final Intent intent = new Intent();
                intent.putExtra("time", time);
                setResult(9, intent);
                finish();
            }
        });
        time = System.currentTimeMillis();
    }
}
